﻿@model IEnumerable<Ecommerce.Areas.Manager.Models.Product>
@{
    ViewBag.Title = "List of product";
}
<p>
    @Html.ActionLink("Add new product", "Regist")
</p>
<fieldset>
    <legend>Categories List</legend>
    <p class="field-validation-error">
        @ViewBag.ErrorMsg
    </p>
    <table border="0">
        <thead>
            <tr>
                <td>Product name</td>
                <td>Category</td>
                <td>Price</td>
                <td>Status</td>
                <td>Action</td>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                <tr>
                    <td>@Html.ActionLink(item.ProdName,"Detail",new { ID = item.ProductID }) </td>
                    <td>@Html.DisplayFor(modelItem => item.Category.CategoryName)</td>
                    <td>@Html.DisplayFor(modelItem => item.Price)</td>
                    <td>@Html.DisplayFor(modelItem => item.StatusName)</td>
                    <td>@Html.ActionLink("Edit", "Edit", new { id = item.ProductID })
                        &nbsp;
                            @Html.ActionLink("Delete", "Delete", new { id = item.ProductID }, new { @class = "delLink" })</td>
                </tr>
            }
        </tbody>
    </table>
</fieldset>
<script type="text/javascript">
    $(document).ready(function () {

        $(".delLink").click(function () {

            return confirm("Are you sure want to delete this product?");
        });
    });
</script>